package br.com.zeneplayer.view;

import java.awt.Component;
import java.io.File;
import java.net.MalformedURLException;

import javax.swing.JFileChooser;

public class FileSystemUtils
{
	/**
	 * Select a system path.
	 * 
	 * @throws MalformedURLException 
	 */
	public static String selectPath(Component component)
	throws MalformedURLException
    {
        File directory = new File(System.getProperty("user.home"));
        
        JFileChooser chooser = new JFileChooser(directory);
        
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
//      chooser.setAcceptAllFileFilterUsed(false);
        
        int approval = chooser.showOpenDialog(component);
        
        if (approval == JFileChooser.APPROVE_OPTION)
        {
        	directory = chooser.getSelectedFile();

            return directory.getAbsolutePath();
        }
        
        return null;
    }
}
